package com.ddtech.business.web.controller;


import com.ddtech.business.web.entity.CollectRecord;
import com.ddtech.business.web.query.CollectRecordQuery;
import com.ddtech.business.web.service.CollectRecordService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 收藏记录表 前端控制器
 * </p>
 *
 * @author bin_pu
 * @since 2023-02-06
 */
@Api(tags = "业务-收藏记录")
@RestController
@RequestMapping("/web/collect-record")
public class CollectRecordController {
    @Autowired
    private CollectRecordService collectRecordService;

    @ApiOperation(value = "分页查询课程收藏记录表")
    @GetMapping(value = "/page-list")
    public ResponseEntity getPageList(CollectRecordQuery collectRecordQuery) {
        return new ResponseEntity(collectRecordService.pageList(collectRecordQuery), HttpStatus.OK);
    }

    @ApiOperation(value = "分页查询试题收藏记录表")
    @GetMapping(value = "/page-list-tm")
    public ResponseEntity getPageListTm(CollectRecordQuery collectRecordQuery) {
        return new ResponseEntity(collectRecordService.pageListTm(collectRecordQuery), HttpStatus.OK);
    }

    @ApiOperation(value = "新增收藏记录,返回收藏信息,PC端")
    @PostMapping(value = "/create")
    public ResponseEntity create(@RequestBody CollectRecord collectRecord) {
        return new ResponseEntity(collectRecordService.create(collectRecord),HttpStatus.OK);
    }


    @ApiOperation(value = "删除收藏记录")
    @PostMapping(value = "/del/{id}")
    public ResponseEntity del(@PathVariable String id) {
        collectRecordService.del(id);
        return new ResponseEntity(HttpStatus.OK);
    }

    @ApiOperation(value = "取消收藏")
    @PostMapping(value = "/cancelCollect/{id}")
    public ResponseEntity cancelCollect(@PathVariable String id) {
        collectRecordService.cancelCollect(id);
        return new ResponseEntity(true,HttpStatus.OK);
    }

    @ApiOperation(value = "查询收藏考试习题信息")
    @GetMapping(value = "/question-page-list")
    public ResponseEntity getQuestionPageList(CollectRecordQuery collectRecordQuery) {
        return new ResponseEntity(collectRecordService.getQuestionPageList(collectRecordQuery), HttpStatus.OK);
    }

    @ApiOperation(value = "查询收藏题库习题信息")
    @GetMapping(value = "/bank-page-list")
    public ResponseEntity getBankPageList(CollectRecordQuery collectRecordQuery) {
        return new ResponseEntity(collectRecordService.getBankPageList(collectRecordQuery), HttpStatus.OK);
    }

    @ApiOperation(value = "查询个人课程收藏、PC、移动端app")
    @GetMapping(value = "/person-collect-course-list")
    public ResponseEntity getPersonCollectCourseList(CollectRecordQuery collectRecordQuery) {
        return new ResponseEntity(collectRecordService.personCollectCourseList(collectRecordQuery), HttpStatus.OK);
    }
}
